package com.ccb.jyzx.expand.tiantouonline.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author XIEFEI
 * @date 2018-11-20 13:35
 * @Description 日期转化工具
 **/
public class ParseDateUtils {
    public static final SimpleDateFormat DAY_FOMAT=new SimpleDateFormat("yyyyMMdd");
    public static final SimpleDateFormat TIME_FARMAT=new SimpleDateFormat("yyyyMMddHHmmss");
    public static final SimpleDateFormat SIMPLE_DATE_FORMAT=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private static final int SUM_LEN=14;

    public static synchronized String getFormateTime(Long time){
        if (time!=null){
            String str= time.toString();
            if (str.length()==SUM_LEN){
                String year= str.substring(0,4);
                String month=str.substring(4,6);
                String day=str.substring(6,8);
                String hour=str.substring(8,10);
                String min=str.substring(10,12);
                String sec=str.substring(12,14);

                return year+"-"+month+"-"+day+" "+hour+":"+min+":"+sec;
            }else{
                return "";
            }
        }
        return "";
    }

    public static synchronized Long getFormateTimeLong(){
        return Long.valueOf(TIME_FARMAT.format(new Date()));
    }

    public static synchronized Long getFormateTimeLong(Date date){

        return Long.valueOf(TIME_FARMAT.format(date));
    }

    public static synchronized String getTimeStameStr(){
        return SIMPLE_DATE_FORMAT.format(new Date());
    }



}
